package com.dd.keel.core.common.utils;

import java.io.File;
import java.io.FileFilter;

import java.util.Map;
import java.util.Collections;
import java.util.HashMap;


public class RegexFileFilter implements FileFilter{
		
	private String fileNamePattern = "_NA_";
	
	public RegexFileFilter(String fileNamePattern)
	{
		if(fileNamePattern!=null) this.fileNamePattern = fileNamePattern;
	}
	
	public boolean accept(File pathname) {
		//LOGGER.trace(pathname.getName());
		if(fileNamePattern.equals("_NA_"))
		{
			if(pathname.isFile() && !pathname.isHidden() )
			{
				//LOGGER.trace("true");
				return true;
			}
		}
		else
		{
			if(pathname.isFile() && !pathname.isHidden() && RegexUtil.match(fileNamePattern, pathname.getName()))
			{
				//LOGGER.trace("true");
				return true;
			}
		}
		//LOGGER.trace("false");
		return false;
	}
	
}
